<?php 

$pid=$_GET['id'];
if(isset($pid)){
    // 链接数据库
    $conn = mysqli_connect('127.0.0.1','root','123456','super','3306');

    // 设置查询编码
    mysqli_query($conn,'SET  NAMES UTF8');
    

    // 查询任务列表
    $result = mysqli_query($conn,"SELECT * FROM project_detail WHERE pid=$pid");    
    $data = [];
    
    // 遍历后添加进入
    while ($d = mysqli_fetch_array($result)) {
       array_push($data, $d);
    }

    // 查询项目信息
    $result = mysqli_query($conn,"SELECT * FROM project WHERE id= $pid");    
    $proj = mysqli_fetch_array($result);
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>task</title>
    <link rel="stylesheet" href="../css/common.css">
    <link rel="stylesheet" href="../css/task.css">

    <style>

    </style>
</head>
<body>
<div>
    <header> 
    </header>
    <div class="content">
        <div class="project_header">
            <div class="tasks">
                <a href="#"><h2 id='projectname' name='projectname' method='get'><?php echo($proj['p_name']) ?></h2></a>
                <a href=""><span><?php echo ($proj['p_detail']) ?></span></a>
            </div>
            <div class="pending">
                <table class="table">
                    <tr class="t1">
                        <td><a class="pen1" href="#"><span>1</span></a></td>
                        <td><div class="s"></div></td>
                        <td><a class="pen2" href="#"><span>1</span></a></td>
                        <td><div class="s1"></div></td>
                        <td><a class="pen3" href="#">
                            <img class="img1" src="../images/fit.png" alt="">
                        </a></td>
                    </tr>
                    <tr>
                        <td><span class="span1">待处理任务</span></td>
                        <td></td>
                        <td><span  class="span2">成员</span></td>
                        <td></td>
                        <td><span  class="span3">设置</span></td>
                    </tr>
                </table>
            </div>
            <div>
                <p class="p1"></p>
                <p class="p2"></p>
            </div>
        </div>
        <div class="project_content">
            <div class="pro_ch">
                <h3><a href="#">任务</a></h3>
                <div class="pro_ch1">
                    <span class="span4"><a href="#">添加任务</a></span>
                    <span class="span5"><img class="img2" src="../images/btrigon.png" alt=""></span>
                </div>
            </div>
            <div class="pro_cc">
                <ul class="pul" >
                <?php foreach ($data as $d) { ?>
                    <li class="content1" >
                        <div class="fm_tls"></div>
                        <a href="task-details.php?id=<?php echo($d['id']) ?>">
                            <span name='project_name'><?php echo($d['t_name']) ?></span>
                        </a>    
                    </li> 
                <?php } ?> 

                    <li class="li">
                        <div class="fm_t">
                            <div class="fm_tl"></div>
                            <p id="fm_tc"><input class="fm_tc" id='t_name' name='t_name' type="text" placeholder="新的任务"></p>
                            <a  class="fm_tr" href="#">未指派~没有截止时间</a>
                        </div>
                        <div class="fm_d">
                            <a href="#"><span class="fm_ds">添加任务</span></a>
                            <span class='del'>取消</span>
                        </div>
                    </li>

                </ul>
            </div>
        </div>
    </div>
</div>
<input type="hidden" id="p_id" value="<?php echo $_GET['id'] ?>">
<script src="../js/jquery-3.1.1.js"></script>
<script src="../js/task.js"></script>
<script src="../js/common.js"></script>
</body>
</html>